package com.example.chengenglong;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.RecyclerView;

import com.example.myapplication.R;

import java.util.ArrayList;

public class DetailAdapter extends RecyclerView.Adapter<DetailAdapter.ViewHolder> {
    private final ArrayList<WeatherInfo> arrayList;

    public DetailAdapter(ArrayList<WeatherInfo> arrayList) {
        this.arrayList = arrayList;
    }


    @NonNull
    @Override
    public DetailAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_detail,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        WeatherInfo info = arrayList.get(position);
        holder.weatherInfo.setText(info.getHumidity()+","+info.getWea()+","+info.getTem()+","+info.getWin()+","+info.getWin_meter());
    }

    @Override
    public int getItemCount() {
        return arrayList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        private final AppCompatTextView weatherInfo;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            weatherInfo = itemView.findViewById(R.id.weatherInfo);
        }
    }


}
